package com.huawei.Galenus.dao;

import com.huawei.Galenus.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserRepository {

    @Insert("insert into user(id,username,password,type,memberlevel,enjoyvalue) " +
            "values(#{id},#{username},#{password},#{type},#{memberlevel},#{enjoyvalue})")
    int save(User user);

    @Select("select * from user where username=#{username}")
    User findByUsername(@Param("username")String username);

    @Select("select * from user where id=#{id}")
    User findById(@Param("id") String id);

    @Select("select * from user where type=1")
    List<User> selectSingers();

    @Update("update user set type=1 where id=#{uid}")
    Integer updateType(@Param("uid") String uid);

    @Update("update user set memberlevel=1 where id=#{uid}")
    int beMember(@Param("uid") String uid);

    @Update("update user set enjoyvalue=enjoyvalue+#{amount} where id=#{uid}")
    int enjoy(@Param("uid") String uid, @Param("amount") int amount);
}

